package com.vancouver.knows.ui.activity.citydiscount;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.vancouver.knows.R;

/**
 * Created by chenxunlin01 on 2016/6/8.
 */
public class MapSelectWindow extends Dialog {

    private TextView all, food,otherThanFood,cancel;
    private View mMenuView;

    public MapSelectWindow(Activity context, View.OnClickListener itemsOnClick) {
        super(context, R.style.SelectPicTheme);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.map_selector_layout, null);
        all = (TextView) mMenuView.findViewById(R.id.map_all);
        food = (TextView) mMenuView.findViewById(R.id.map_food);
        otherThanFood = (TextView) mMenuView.findViewById(R.id.map_other);
        cancel = (TextView) mMenuView.findViewById(R.id.map_cancel);
        // 取消按钮
        cancel.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // 销毁弹出框
                dismiss();
            }
        });
        // 设置按钮监听
        all.setOnClickListener(itemsOnClick);
        food.setOnClickListener(itemsOnClick);
        otherThanFood.setOnClickListener(itemsOnClick);
        WindowManager.LayoutParams windowAttributes = this.getWindow().getAttributes();
        windowAttributes.gravity = Gravity.BOTTOM;
        this.setCancelable(true);

        WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics metric = new DisplayMetrics();
        windowManager.getDefaultDisplay().getMetrics(metric);
        int width = metric.widthPixels;

        this.setContentView(mMenuView, new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
}
